﻿using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Serialization;
using ChainAnalises.Classes.AuxiliaryClasses.WebServices.SOAP;
using ChainAnalises.Classes.IntervalAnalysis;
using CharacteristicCalculator.Controller;
using MySql.Data.MySqlClient;
using SharedData;

namespace CharacteristicCalculator
{
    /// <summary>
    /// Главная форма приложения
    /// </summary>
    public partial class Form1 : Form
    {
        private MySqlConnection Connection = null;
        private MySqlDataReader DRQuery = null;

        public Form1()
        {
            InitializeComponent();

            //Соединение с БД
            MySqlConnectionStringBuilder config_string = new MySqlConnectionStringBuilder();
            config_string.UserID = "root";
           // config_string.Password = "root";
            config_string.Database = "Complex_work";
            config_string.Server = "localhost";
            Connection = new MySqlConnection(config_string.ConnectionString);

            int k = 0;

            //пытаемся выполнить запрос к БД
            try
            {
                Connection.Open();
                //SQL запрос
                string sql = "SELECT ob.object_name, ob.object_description, ob_typ.object_type_name, ob_typ.object_type_description, fl.file_name, fl.file_description, fl.file_file FROM object ob JOIN object_type ob_typ ON ob.object_type_id = ob_typ.object_type_id JOIN sequence sq ON sq.object_id = ob.object_id JOIN files fl ON fl.file_id = sq.file_id WHERE ob_typ.object_type_name =  'DNA'";
                MySqlCommand command = Connection.CreateCommand();
                command.CommandText = sql;
                DRQuery = command.ExecuteReader();

                //Разбор SQL запроса
                while (DRQuery.Read())
                {
                    string name = DRQuery.GetString(4);
                    string chain = DRQuery.GetString(6);
                    //фильтрация мусора
                    if (((chain[1] == 'C') || (chain[1] == 'T') || (chain[1] == 'G') || (chain[1] == 'A')) && ((chain[0] == 'C') || (chain[0] == 'T') || (chain[0] == 'G') || (chain[0] == 'A')))
                    {
                        dataGridView1.Rows.Add();
                        dataGridView1.Rows[k].Cells[0].Value = k + 1;
                        dataGridView1.Rows[k].Cells[2].Value = name;
                        dataGridView1.Rows[k].Cells[3].Value = chain;
                        k++;
                    }
                }
                Connection.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Ошибка подключения к БД", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Environment.Exit(0);
                return;
            }

            dataGridView1.Rows.Add();
            dataGridView1.Rows[k].Cells[0].Value = k + 1;
            dataGridView1.Rows[k].Cells[2].Value = "Bos taurus 18S ribosomal RNA gene - Дикий бык";
            dataGridView1.Rows[k].Cells[3].Value = "TACCTGGTTGATCCTGCCAGTAGCATATGCTTGTCTCAAAGATTAAGCCATGCATGTCTAAGTACGCACGGCCGGTACAGTGAAACTGCGAATGGCTCATTAAATCAGTTATGGTTCCTTTGGTCGCTCGCTCCTCTCCTACTTGGATAACTGTGGTAATTCTAGAGCTAATACATGCCGACGGGCGCTGACCCCCTTCGCGGGGGGGATGCGTGCATTTATCAGATCAAAACCAACCCGGTCAGCCTCCTCCCGGCCCCGGCCGGGGGGCGGGCGCCGGCGGCTTTGGTGACTCTAGATAACCTCGGGCCGATCGCACGCCCCCCGTGGCGGCGACGACCCATTCGAACGTCTGCCCTATTAACTTTCGATGGTAGTCGCTGTGCCTACCATGGTGACCACGGGTGACGGGGAATCAGGGTTCGATTCCGGAGAGGGAGCCTGAGAAACGGCTACCACATCCAAGGAAGGCAGCAGGCGCGCAAATTACCCACTCCCGACCCGGGGAGGTAGTGACGAAAAATAACAATACAGGACTCTTTCGGGGCCCTGTAATTGGAATGAGTCCACTTTAAATCCTTTAACGAGGATCCATTGGAGGGCAAGTCTGGCGCCAGCAGCCGCGGTAATTCCAGCTCCAATAGCGTATATTAAAGTTGCTGCAGTTAAAAAGCTCGTAGTTGGATCTTGGGAGCGGGCGGGCGGTCCGCCGCGAGGCGAGCCACCGCCCGTCCCCGCCCCTTGCCTCTCGGCGCCCCCTCGATGCTCTTAGCTGAGTGTCCCTCGGGGCCCGAAGCGTTTACTTTGAAAAAATTAGAGTGTTCAAAGCAGGCCCGAGCCGCCTGGATACCGCAGCTAGGAATAATGGAATAGGACCGCGGTTCTATTTTGTTGGTTTTCGGAACTGAGGCCATGATTAAGAGGGGCGGCCGGGGGCATTCGTATTGCGCCGCTAGAGGTGAAATTCTTGGATCGGCGCAAGACGGACCAGAGCGAAAGCATTTGCCAAGAATGTTTTCATTAATCAAGAACGAAAGTCGGAGGTTCGAAGACGATCAGATACCGTCGTAGTTCCGACCATAAACGATGCCGACCGGCGATGCGGCGGCGTTATTCCCATGACCCGCCGGGCAGCTTCCGGGAAACCAAAGTCTTTGGGTTCCGGGGGGAGTATGGTTGCAAAGCTGAAACTTAAAGGAATTGACGGAAGGGCACCACCAGGAGTGGAGCCTGCGGCTTAATTTGACTCAACACGGGAAACCTCACCCGGCCCGGACACGGACAGGATTGACAGATTGATAGCTCTTTCTCGATTCCGTGGGTGGTGGTGCATGGCCGTTCTTAGTTGGTGGAGCGATTTGTCTGGGTTAATTCCGATAACGAACGAGACTCTGGGCATGCTAACTAGTTACGCGACCCCGAGACGGTCGGGCGTCCCCCAACTTCTTAGAGGGACAAGTGGCGTTCAGCCACCCGAGATTGAGCAATAACAGGTCTGTGATGCCCTTAGATGTCCGGGGCTGCACGCGCGCTACACTGACTGGCTCAGCGTGTGCCTACCCTACGCCGGCAGGCGCGGGTAACCCGTTGAACCCCATTCGTGATGGGGATCGGGGATTGCAATTATTCCCCATGAACGAGGAATTCCCAGTAAGTGCGGGTCATAAGCTTGCGTTGATTAAGTCCCTGCCCTTTGTACACACCCGCCCGTCGCTACTACCGATTGGATGGTTTAGTGAGGCCCTCGGATCGGCCCCGCCGGGGTCGGCCCACGGCCCTGGCGGAGCGCTGAGAAGACGGTCGAACTTGACTATCTAGAGGAAGTAAAAGTCGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTA";
            k++;
            dataGridView1.Rows.Add();
            dataGridView1.Rows[k].Cells[0].Value = k + 1;
            dataGridView1.Rows[k].Cells[2].Value = "Cricetulus griseus - серый хомячок";
            dataGridView1.Rows[k].Cells[3].Value = "TACCTGGTTGATCCTGCCAGTAGCATATGCTTGTCTCAAAGATTAAGCCATGCATGTCTAAGTACGCACGGCCGGTACAGTGAAACTGCGAATGGCTCATTAAATCAGTTATGGTTCCTTTGGTCGCTCGCTCCTCTCCTACTTGGATAACTGTGGTAATTCTAGAGCTAATACATGCCGACGGGCGCTGACCCCCTTCGCGGGGGGGATGCGTGCATTTATCAGATCAAAACCAACCCGGTCAGCTTCCTTCCCGGCTCCGGCCGGGGGGGCGGGCGCCGGCGGCTTTGGTGACTCTAGATAACCTCGGGCCGATCGCACGCCCCCCGTGGCGGCGACGACCCATTCGAACGTCTGCCCTATCAACTTTCGATGGTAGTCGATGTGCCTACCATGGTGACCACGGGTGACGGGGAATCAGGGTTCGATTCCGGAGAGGGAGCCTGAGAAACGGCTACCACATCCAAGGAAGGCAGCAGGCGCGCAAATTACCCACTCCCGACCCGGGGAGGTAGTGACGAAAAATAACAATACAGGACTCTTTCGAGGCCCTGTAATTGGAATGAGTCCACTTTAAATCCTTTAACGAGGATCCATTGGAGGGCAAGTCTGGTGCCAGCAGCCGCGGTAATTCCAGCTCCAATAGCGTATATTAAAGTTGCTGCAGTTAAAAAGCTCGTAGTTGGATCTTGGGAGCGGGCGGGCGGTCCGCCGCGAGGCGAGTCACCGCCCGTCCCCGCCCCTTGCCTCTCGGCGCCCCCTCGATGCTCTTAGCTGAGTGTCCCGCGGGGCCCGAAGCGTTTACTTTGAAAAAATTAGAGTGTTCAAAGCAGGCCCGAGCCGCCTGGATACCGCAGCTAGGAATAATGGAATAGGACCGCGGTTCTATTTTGTTGGTTTTCGGAACTGAGGCCATGATTAAGAGGGACGGCCGGGGGCATTCGTATTGCGCCGCTAGAGGTGAAATTCTTGGACCGGCGCAAGACGGACCAGAGCGAAAGCATTTGCCAAGAATGTTTTCATTAATCAAGAACGAAAGTCGGAGGTTCGAAGACGATCAGATACCGTCGTAGTTCCGACCATAAACGATGCCGACTGGCGATGCGGCGGCGTTATTCCCATGACCCGCCGGGCAGCTTCCGGGAAACCAAAGTCTTTGGGTTCCGGGGGGAGTATGGTTGCAAAGCTGAAACTTAAAGGAATTGACGGAAGGGCACCACCAGGAGTGGAGCCTGCGGCTTAATTTGACTCAACACGGGAAACCTCACCCGGCCCGGACACGGACAGGATTGACAGATTGATAGCTCTTTCTCGATTCCGTGGGTGGTGGTGCATGGCCGTTCTTAGTTGGTGGAGCGATTTGTCTGGTTAATTCCGATAACGAACGAGACTCTGGCATGCTAACTAGTTACGCGACCCCCGAGCGGTCGGCGTCCCCCAACTTCTTAGAGGGACAAGTGGCGTTCAGCCACCCGAGATTGAGCAATAACAGGTCTGTGATGCCCTTAGATGTCCGGGGCTGCACGCGCGCTACACTGACTGGCTCAGCGTGTGCCTACCCTACGCCGGCAGGCGCGGGTAACCCGTTGAACCCCATTCGTGATGGGGATCGGGGATTGCAATTATTCCCCATGAACGAGGAATTCCCAGTAAGTGCGGGTCATAAGCTTGCGTTGATTAAGTCCCTGCCCTTTGTACACACCGCCCGTCGCTACTACCGATTGGATGGTTTAGTGAGGCCCTCGGATCGGCCCCGCCGGGGTCGGCCCACGGCCCTGGCGGAGCGCTGAGAAGACGGTCGAACTTGACTATCTAGAGGAAGTAAAAGTCGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTA";
            k++;
            dataGridView1.Rows.Add();
            dataGridView1.Rows[k].Cells[0].Value = k + 1;
            dataGridView1.Rows[k].Cells[2].Value = "Crocodylus niloticus - Нильский крокодил";
            dataGridView1.Rows[k].Cells[3].Value = "AGCATATGCTTGTCTCAAAGATTAAGCCATGCATGTCTAAGTACACACGGCCGGTACAGTGAAACTGCGAATGGCTCATTAAATCAGTTATGGTTCCTTTGGTCGCTCCAACCGTTACTTGGATAACTGTGGTAATTCTAGAGCTAATACATGCCGACGAGCGCCGACCTCCGGGGACGCGTGCATTTATCAGACCAAAACCAACCCGGGCCCGCCCGGCCGCTTTGGTGACTCTAGATAACCTCGAGCCGATCGCACGCCCCCGCGGCGGCGACGACCCATTCGAATGTCTGCCCTATCAACTTTCGATGGTACTGTCTGTGCCTACCATGGTGACCACGGGTGACGGGGAATCAGGGTTCGATTCCGGAGAGGGAGCCTGAGAAACGGCTACCACATCCAAGGAAGGCAGCAGGCGCGCAAATTACCCACTCCCGACCCGGGGAGGTAGTGACGAAAAATAACAATACAGGACTCTTTCGAGGCCCTGTAATTGGAATGAGCGCACTTTAAATCCTTGAGCGAGGATCCATTGGAGGGCAAGTCTGGTGCCAGCAGCCGCGGTAATTCCAGCTCCAATAGCGTATCTTAAAGTTGCTGCAGTTAAAAAGCTCGTAGTTGGATCTTGGGATCGAGCTGGCGGTCCGCCGCGAGGCGAGCCACCGCCTGTCCCAGCCCCTGCCTCTCGGCGCCCCCTTGATGCTCTTAGCTGAGTGTCCCGCGGGGCCCGAAGCGTTTACTTTGAAAAAATTAGAGTGTTCAAAGCAGGCCGGCCGCCGGAATACTCCAGCTAGGAATAATGGAATAGGACTCCGGTTCTATTTTGTTGGTTTTCGGAACTGGGGCCATGATTAAGAGGGACGGCCGGGGGCATTCGTATTGTGCCGCTAGAGGTGAAATTCTTGGACCGGCGCAAGACGGACCAAAGCGAAACATTTGCCAAGAATGTTTTCATTAATCAAGAACGAAAGTCGGAGGTTCGAAGACGATCAGATACCGTCGTAGTTCCGACCATAAACGATGCCGACTAGCGATCCGGCGGCGTTATTCCCATGACCCGCCGGGCAGCTTCCGGGAAACCAAAGTCTTTGGGTTCCGGGGGGAGTATGGTTGCAAAGCTGAAACTTAAAGGAATTGACGGAAGGGCACCACCAGGAGTGGAGCCTGCGGCTTAATTTGACTCAACACGGGAAACCTCACCCGGCCCGGACACGGAAAGGATTGACAGATTGATAGCTCTTTCTCGATTCTGTGGGTGGTGGTGCATGGCCGTTCTTAGTTGGTGGAGCGATTTGTCTGGTTAATTCCGATAACGAACGAGACTCTGGCATGCTAACTAGTTATGCGACCCCCGAGCGGTCGGCGTCCAACTTCTTAGAGGGACAAGTGGCGTTCAGCCACCCGAGATTGAGCAATAACAGGTCTGTGATGCCCTTAGATGTCCGGGGCTGCACGCGCGCTACACTGACTGGCTCAGCGTGTGTCTACCCTACGCCGACAGGTGCGGGTAACCCGTTGAACCCCATTCGTGATGGGGATCGGGGATTGCAATTATTCCCCATGAACGAGGAATTCCCAGTAAGTGCGGGTCATAAGCTCGCGTTGATTAAGTCCCTGCCCTTTGTACACACCGCCCGTCGCTACTACCGATTGGATGGTTTAGTGAGGTCCTCGGATCGGCCCCGCCGGGGTCGGTCACGGCCCTGGCGGAGCGCCGAGAAGACGGTCGAACTTGACTATCTAGAGGAAGTAAAAGTCGTAACAAGGTTTCCGTAG";
            k++;
            dataGridView1.Rows.Add();
            dataGridView1.Rows[k].Cells[0].Value = k + 1;
            dataGridView1.Rows[k].Cells[2].Value = "Erinaceus europaeus - Обыкновенный ёж";
            dataGridView1.Rows[k].Cells[3].Value = "AGCATATGCTTGTCTCAAAGATTAAGCCATGCATGTCTAAGTACGCACGGCCGGTACAGTGAAACTGCGAATGGCTCATTAAATCAGTTATGGTTCCTTTGGTCGCTCGCTCCTCTCCTACTTGGATAACTGTGGTAATTCTAGAGCTAATACATGCCGACGGGCGCTGACCCCCTTCGCGGGGGGGATGCGTGCATTTATCAGATCAAAACCAACCCGGTCAGCCTCCCTCCGGCTCCGGCCGGGGGGGCGGGCGCCGGCGGCTTTGGTGACTCTAGATAACCTCGGGCCGATCGCACGCCCCCCGTGGCGGCGACGACCCATTCGAACGTCTGCCCTATCAACTTTCGATGGTAGTCGCCGTGCCTACCATGGTGACCACGGGTGACGGGGAATCAGGGTTCGATTCCGGAGAGGGAGCCTGAGAAACGGCTACCACATCCAAGGAAGGCAGCAGGCGCGCAAATTACCCACTCCCGACCCGGGGAGGTAGTGACGAAAAATAACAATACAGGACTCTTTCGAGGCCCTGTAATTGGAATGAGTCCACTTTAAATCCTTTAACGAGGATCCATTGGAGGGCAAGTCTGGTGCCAGCAGCCGCGGTAATTCCAGCTCCAATAGCGTATATTAAAGTTGCTGCAGTTAAAAAGCTCGTAGTTGGATCTTGGGAGCGGGCGGGCGGTCCGCCGCGAGGCGAGCCACCGCCCGTCCCCGCCCCTTGCCTCTCGGCGCCCCCTCGATGCTCTTAGCTGAGTGTCCCGCGGGGCCCGAAGCGTTTACTTTGAAAAAATTAGAGTGTTCAAAGCAGGCCCGAGCCGCCTGGATACCGCAGCTAGGAATAATGGAATAGGACCGCGGTTCTATTTTGTTGGTTTTCGGAACTGAGGCCATGATTAAGAGGGACGGCCGGGGGCATTCGTATTGCGCCGCTAGAGGTGAAATTCTTGGACCGGCGCAAGACGGACCAGAGCGAAAGCATTTGCCAAGAATGTTTTCATTAATCAAGAACGAAAGTCGGAGGTTCGAAGACGATCAGATACCGTCGTAGTTCCGACCATAAACGATGCCGACTGGCGATGCGGCGGCGTTATTCCCATGACCCGCCGGGCAGCTTCCGGGAAACCAAAGTCTTTGGGTTCCGGGGGGAGTATGGTTGCAAAGCTGAAACTTAAAGGAATTGACGGAAGGGCACCACCAGGAGTGGAGCCTGCGGCTTAATTTGACTCAACACGGGAAACCTCACCCGGCCCGGACACGGACAGGATTGACAGATTGATAGCTCTTTCTCGATTCCGTGGGTGGTGGTGCATGGCCGTTCTTAGTTGGTGGAGCGATTTGTCTGGTTAATTCCGATAACGAACGAGACTCTGGCATGCTAACTAGTTACGCGACCCCCGAGCGGTCGGCGTCCCCCAACTTCTTAGAGGGACAAGTGGCGTTCAGCCACCCGAGATTGAGCAATAACAGGTCTGTGATGCCCTTAGATGTCCGGGGCTGCACGCGCGCTACACTGACTGGCTCAGCGTGTGCCTACCCTACGCCGGCAGGCGCGGGTAACCCGTTGAACCCCATTCGTGATGGGGATCGGGGATTGCAATTATTCCCCATGAACGAGGAATTCCCAGTAAGTGCGGGTCATAAGCTTGCGTTGATTAAGTCCCTGCCCTTTGTACACACCGCCCGTCGCTACTACCGATTGGATGGTTTAGTGAGGCCCTCGGATCGGCCCCGCCGGGGTCGGCCCACGGCCTGGCGGAGCGCTGAGAAGACGGTCGAACTTGACTATCTAGAGGAAGTAAAAGTCGTAACAAGGTTTCCGTAG";
            k++;
            dataGridView1.Rows.Add();
            dataGridView1.Rows[k].Cells[0].Value = k + 1;
            dataGridView1.Rows[k].Cells[2].Value = "Gallus gallus - Банкивская джунглевая курица";
            dataGridView1.Rows[k].Cells[3].Value = "ATTCCTTTGGTCGCTCCCCTCCCGTTACTTGGATAACTGTGGTAATTCTAGAGCTAATACATGCCGACGAGCGCCGACCTCCGGGGACGCGTGCATTTATCAGACCAAAACCAACCCGGGCTCGCCCGGCGGCTTTGGTGACTCTAGATAACCTCGAGCCGATCGCACGCCCCCGTGGCGGCGACGACCCATTCGAATGTCTGCCCTATCAACTTTCGATGGTACTGTCTGTGCCTACCATGGTGACCACGGGTAACGGGGAATCAGGGTTCGATTCCGGAGAGGGAGCCTGAGAAACGGCTACCACATCCAAGGAAGGCAGCAGGCGCGCAAATTACCCACTCCCGACCCGGGGAGGTAGTGACGAAAAATAACAATACAGGACTCTTTCGAGGCCCTGTAATTGGAATGAGTCCACTTTAAATCCTTTAACGAGGATCCATTGGAGGGCAAGTCTGGTGCCAGCAGCCGCGGTAATTCCAGCTCCAATAGCGTATATTAAAGTTGCTGCAGTTAAAAAGCTCGTAGTTGGATCTTGGGATCGAGCTGGCGGTCCGCCGCGAGGCGAGCTACCGCCTGTCCCAGCCCCTGTCTCTCGGCGCCCCCTCGATGCTCTTAACTGAGTGTCCCGCGGGGGCCCGACCCGTTTACTTTGAAAAAAATTAGAGTGGTCAAAGCAGGCTGGCCGCCGGAATACTCCAGCTAGGAATAATGGAATAGGACTCCGGTTCTATCTTGTTGGTTTTCGGAAACGGGGCCATGATTAAGAGGGACGGCCGGGGGCATTCGTATTGTGCCGCTAGAGGTGAAATTCTTGGACCGGCGCAAGACGAACTAAAGCGAAAGCATTTGCCAAGAATGTTTTCATTAATCAAGAACGAAAGTCGGAGGTTCGAAGACGATCAGATACCGTCGTAGTTCCGACCATAAACGATGCCGACTCGCGATCCGGCGGCGTTATTCCCATGACCCGCCGGGCAGCTCCCGGGAAACCCAAGTCTTTGGGTTCCGGGGGGAGTATGGTTGCAAAGCTGAAACTTAAAGGAATTGACGGAAGGGCACCACCAGGAGTGGAGCCTGCGGCTTAATTTGACTCAACACGGGAAACCTCACCCGGCCCGGACACGGACAGGATTGACAGATTGAGAGCTCTTTCTCGATTCCGTGGGTGGTGGTGCATGGCCGTTCTTAGTTGGTGGAGCGATTTGTCTGGTTAATTCCGATAACGAACGAGACTCTGGCATGCTAACTAGTTACGCGACCCCCGAGCGGTCGGCGTCCAACTTCTTAGAGGGACAAGTGGCGTTCAGCCACCCGAGATTGAGCAATAACAGGTCTGTGATGCCCTTAGATGTCCGGGGCTGCACGCGCGCTACACTGACTGGCTCAGCTTGTGTCTACCCTACGCCGGCAGACGCGGGTAACCCGTTGAACCCCATTCGTGATGGGGATCGGGGATTGCAATTATTCCCCATGAACGAGGAATTCCCAGTAAGTGCGGGTCATAAGCTCGCGTTGATTAAGTCCCTGCCCTTTGTACACACCGCCCGTCGCTACTACCGATTGGATGGTTTAGTGAGGTCCTCGGATCGGCCCCGGCGGGGTCGGCCACGGCCCTGCCGGAGCGTCGAGAAGACGGTCGAACTTGACTATCTAGAGGAAGTAAAAGTCGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTACCGGGGCCGAGGCCGGGCGTCCGGCCGAGCCGTGGCACGAGCGCGCGCGGGCGCGCAGCCTTCCCTTCCCTTCCCCGAGCCCGCTCCGCGCGGAGCGCGGCTCCTCTCCCCCGGTCGAAACGGGGAAAGAAAAAAAAAA";
            k++;
            dataGridView1.Rows.Add();
            dataGridView1.Rows[k].Cells[0].Value = k + 1;
            dataGridView1.Rows[k].Cells[2].Value = "Homo sapiens - Человек разумный";
            dataGridView1.Rows[k].Cells[3].Value = "TACCTGGTTGATCCTGCCAGTAGCATATGCTTGTCTCAAAGATTAAGCCATGCATGTCTGAGTACGCACGGCCGGTACAGTGAAACTGCGAATGGCTCATTAAATCAGTTATGGTTCCTTTGGTCGCTCGCTCCTCTCCTACTTGGATAACTGTGGTAATTCTAGAGCTAATACATGCCGACGGGCGCTGACCCCCTTCGCGGGGGGGATGCGTGCATTTATCAGATCAAAACCAACCCGGTCAGCCCCTCTCCGGCCCCGGCCGGGGGGCGGGCGCCGGCGGCTTTGGTGACTCTAGATAACCTCGGGCCGATCGCACGCCCCCCGTGGCGGCGACGACCCATTCGAACGTCTGCCCTATCAACTTTCGATGGTAGTCGCCGTGCCTACCATGGTGACCACGGGTGACGGGGAATCAGGGTTCGATTCCGGAGAGGGAGCCTGAGAAACGGCTACCACATCCAAGGAAGGCAGCAGGCGCGCAAATTACCCACTCCCGACCCGGGGAGGTAGTGACGAAAAATAACAATACAGGACTCTTTCGAGGCCCTGTAATTGGAATGAGTCCACTTTAAATCCTTTAACGAGGATCCATTGGAGGGCAAGTCTGGTGCCAGCAGCCGCGGTAATTCCAGCTCCAATAGCGTATATTAAAGTTGCTGCAGTTAAAAAGCTCGTAGTTGGATCTTGGGAGCGGGCGGGCGGTCCGCCGCGAGGCGAGCCACCGCCCGTCCCCGCCCCTTGCCTCTCGGCGCCCCCTCGATGCTCTTAGCTGAGTGTCCCGCGGGGCCCGAAGCGTTTACTTTGAAAAAATTAGAGTGTTCAAAGCAGGCCCGAGCCGCCTGGATACCGCAGCTAGGAATAATGGAATAGGACCGCGGTTCTATTTTGTTGGTTTTCGGAACTGAGGCCATGATTAAGAGGGACGGCCGGGGGCATTCGTATTGCGCCGCTAGAGGTGAAATTCTTGGACCGGCGCAAGACGGACCAGAGCGAAAGCATTTGCCAAGAATGTTTTCATTAATCAAGAACGAAAGTCGGAGGTTCGAAGACGATCAGATACCGTCGTAGTTCCGACCATAAACGATGCCGACCGGCGATGCGGCGGCGTTATTCCCATGACCCGCCGGGCAGCTTCCGGGAAACCAAAGTCTTTGGGTTCCGGGGGGAGTATGGTTGCAAAGCTGAAACTTAAAGGAATTGACGGAAGGGCACCACCAGGAGTGGAGCCTGCGGCTTAATTTGACTCAACACGGGAAACCTCACCCGGCCCGGACACGGACAGGATTGACAGATTGATAGCTCTTTCTCGATTCCGTGGGTGGTGGTGCATGGCCGTTCTTAGTTGGTGGAGCGATTTGTCTGGTTAATTCCGATAACGAACGAGACTCTGGCATGCTAACTAGTTACGCGACCCCCGAGCGGTCGGCGTCCCCCAACTTCTTAGAGGGACAAGTGGCGTTCAGCCACCCGAGATTGAGCAATAACAGGTCTGTGATGCCCTTAGATGTCCGGGGCTGCACGCGCGCTACACTGACTGGCTCAGCGTGTGCCTACCCTACGCCGGCAGGCGCGGGTAACCCGTTGAACCCCATTCGTGATGGGGATCGGGGATTGCAATTATTCCCCATGAACGAGGAATTCCCAGTAAGTGCGGGTCATAAGCTTGCGTTGATTAAGTCCCTGCCCTTTGTACACACCGCCCGTCGCTACTACCGATTGGATGGTTTAGTGAGGCCCTCGGATCGGCCCCGCCGGGGTCGGCCCACGGCCCTGGCGGAGCGCTGAGAAGACGGTCGAACTTGACTATCTAGAGGAAGTAAAAGTCGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTA";
            k++;
            dataGridView1.Rows.Add();
            dataGridView1.Rows[k].Cells[0].Value = k + 1;
            dataGridView1.Rows[k].Cells[2].Value = "Kareius bicoloratus - двухцветная камбала";
            dataGridView1.Rows[k].Cells[3].Value = "TCTGGTTGATTCTGCCAGTAGCATATGCTTGTCTCAAAGATTAAGCCATGCAAGTCTAAGTACACACGGCCGGTACAGTGAAACTGCGAATGGCTCATTAAATCAGTTATGGTTCCTTTGATCGCTCTCACGTTACTTGGATAACTGTGGCAATTCCAGAGCTAATACATGCCAACGGGCGCTGACCTCCGGGGACGCGTGCATTTATCAGACCCAAAACCCATGCGGGGTGCTCCTCATGGGGTGCCCCGGCCGCTTTGGTGACTCTAGATAACCTCGAGCTGATCGCTGGCCCTCGTGGCGGCGACGTCTCATTCGAATGTCTGCCCTATCAACTTTCGATGGTACTTTTTGTGCCTACCATGGTGACCACGGGTAACGGGGAATCAGGGTTCGATTCCGGAGAGGGAGCCTGAGAAACGGCTACCACATCCAAGGAAGGCAGCAGGCGCGCAAATTACCCACTCCCGACTCGGGGAGGTAGTGACGAAAAATAACAATACAGGACTCTTTCGAGGCCCTGTAATTGGAATGAGTACACTTTAAATCCTTTAACGAGGATCCATTGGAGGGCAAGTCTGGTGCCAGCAGCCGCGGTAATTCCAGCTCCAATAGCATATCTTAAAGTTGCTGCAGTTAAAAAGCTCGTAGTTGGACCTCGGGATCGAGCTGACGGTCCGCCGCGAGGCGAGCTACCGTCTGTCCCAGCCCCTGCCTCTCGGCGCCCCCTCGATGCTCTTAGCTGAGTGTCCCGCGGGGTCCGAAGCGTTTACTTTGAAAAAATTAGAGTGTTCAAAGCAGGCCCGGTCGCCTGAATACCGCAGCTAGGAATAATGGAATAGGACTCCGGTTCTATTTTGTGGGATTTCTTCTCTGAACTGGGGCCATGATTAAGAGGGACGGCCGGGGGCATTCGTATTGTGCCGCTAGAGGTGAAATTCTTGGACCGGTGCAAGACGGACGAAAGCGAAAGCATTTGCCAAGAATGTTTTCATTAATCAAGAACGAAAGTCGGAGGTTCGAAGATGATCAGATACCGTGGTAGTTCCGACCGTAAACGATGCCAACTAGCGATCCGGCGGCGTTATTCCCATGACCCGCCGGGCAGCGTCCGGGAAACCAAAGTCTTTGGGTTCCGGGGGGAGTATGGTTGCAAAGCTGAAACTTAAAGGAATTGACGGAAGGGCACCACCAGGAGTGGAGCCTGCGGCTTAATTTGACTCAACACGGGAAACCTCACCCGGCCCGGACACGGAAAGGATTGACAGATTGATAGCTCTTTCTCGATTCTGTGGGTGGTGGTGCATGGCCGTTCTTAGTTGGTGGAGCGATTTGTCTGGTTAATTCCGATAACGAACGTGACTCTGGCATGCTAACTAGTTACGCGGCCCCGTGCGGTCGGCGTCCAACTTCTTAGAGGGACAAGTGGAATTTAGCCACACGAGATTGAGCAATAACAGGTCTGTGATGCCCTTAGATGTCCGGGGCTGCACGCGCGCCACACTGACTGGATCAGCGTGTGTCTACCCTTCGCCGAGAGGCGCGGGTAACCCGCTGAACCCCACTCGTGATAGGGATTGGGGATTGCAATTATTTCCCATGAACGAGGAATTCCCAGTAAGCGCGGGTCATAAGCTCGCGTTGATTAAGTCCCTGCCCTTTGTACACACCGCCCGTCGCTACTACCGATTGGATGGTTTAGTGAGGTCCTCGGATCGGTAACGGCCCTGGCGGAGCGCCGAGAAGACGATCAAACTTGACTATCTAGAGGAAGTAAAAGTCGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTA";
            k++;
            dataGridView1.Rows.Add();
            dataGridView1.Rows[k].Cells[0].Value = k + 1;
            dataGridView1.Rows[k].Cells[2].Value = "Mus musculus - Домовая мышь";
            dataGridView1.Rows[k].Cells[3].Value = "ACCTGGTTGATCCTGCCAGGTAGCATATGCTTGTCTCAAAGATTAAGCCATGCATGTCTAAGTACGCACGGCCGGTACAGTGAAACTGCGAATGGCTCATTAAATCAGTTATGGTTCCTTTGGTCGCTCGCTCCTCTCCTACTTGGATAACTGTGGTAATTCTAGAGCTAATACATGCCGACGGGCGCTGACCCCCCTTCCCGGGGGGGGATGCGTGCATTTATCAGATCAAAACCAACCCGGTGAGCTCCCTCCCGGCTCCGGCCGGGGGTCGGGCGCCGGCGGCTTGGTGACTCTAGATAACCTCGGGCCGATCGCACGCCCCCCGTGGCGGCGACGACCCATTCGAACGTCTGCCCTATCAACTTTCGATGGTAGTCGCCGTGCCTACCATGGTGACCACGGGTGACGGGGAATCAGGGTTCGATTCCGGAGAGGGAGCCTGAGAAACGGCTACCACATCCAAGGAAGGCAGCAGGCGCGCAAATTACCCACTCCCGACCCGGGGAGGTAGTGACGAAAAATAACAATACAGGACTCTTTCGAGGCCCTGTAATTGGAATGAGTCCACTTTAAATCCTTTAACGAGGATCCATTGGAGGGCAAGTCTGGTGCCAGCAGCCGCGGTAATTCCAGCTCCAATAGCGTATATTAAAGTTGCTGCAGTTAAAAAGCTCGTAGTTGGATCTTGGGAGCGGGCGGGCGGTCCGCCGCGAGGCGAGTCACCGCCCGTCCCCGCCCCTTGCCTCTCGGCGCCCCCTCGATGCTCTTAGCTGAGTGTCCCGCGGGGCCCGAAGCGTTTACTTTGAAAAAATTAGAGTGTTCAAAGCAGGCCCGAGCCGCCTGGATACCGCAGCTAGGAATAATGGAATAGGACCGCGGTTCTATTTTGTTGGTTTTCGGAACTGAGGCCATGATTAAGAGGGACGGCCGGGGGCATTCGTATTGCGCCGCTAGAGGTGAAATTCTTGGACCGGCGCAAGACGGACCAGAGCGAAAGCATTTGCCAAGAATGTTTTCATTAATCAAGAACGAAAGTCGGAGGTTCGAAGACGATCAGATACCGTCGTAGTTCCGACCATAAACGATGCCGACTGGCGATGCGGCGGCGTTATTCCCATGACCCGCCGGGCAGCTTCCGGGAAACCAAAGTCTTTGGGTTCCGGGGGGAGTATGGTTGCAAAGCTGAAACTTAAAGGAATTGACGGAAGGGCACCACCAGGAGTGGGCCTGCGGCTTAATTTGACTCAACACGGGAAACCTCACCCGGCCCGGACACGGACAGGATTGACAGATTGATAGCTCTTTCTCGATTCCGTGGGTGGTGGTGCATGGCCGTTCTTAGTTGGTGGAGCGATTTGTCTGGTTAATTCCGATAACGAACGAGACTCTGGCATGCTAACTAGTTACGCGACCCCCGAGCGGTCGGCGTCCCCCAACTTCTTAGAGGGACAAGTGGCGTTCAGCCACCCGAGATTGAGCAATAACAGGTCTGTGATGCCCTTAGATGTCCGGGGCTGCACGCGCGCTACACTGACTGGCTCAGCGTGTGCCTACCCTGCGCCGGCAGGCGCGGGTAACCCGTTGAACCCCATTCGTGATGGGGATCGGGGATTGCAATTATTCCCCATGAACGAGGAATTCCCAGTAAGTGCGGGTCATAAGCTTGCGTTGATTAAGTCCCTGCCCTTTGTACACACCGCCCGTCGCTACTACCGATTGGATGGTTTAGTGAGGCCCTCGGATCGGCCCCGCCGGGGTCGGCCCACGGCCCTGGCGGAGCGCTGAGAAGACGGTCGAACTTGACTATCTAGAGGAAGTAAAAGTCGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTAA";
            k++;
            /*dataGridView1.Rows.Add();
            dataGridView1.Rows[k].Cells[0].Value = k + 1;
            dataGridView1.Rows[k].Cells[2].Value = "Rabbit - Кролик";
            dataGridView1.Rows[k].Cells[3].Value = "TACCTGGTTGATCCTGCCAGTAGCATATGCTTGTCTCAAAGATTAAGCCATGCATGTCTAAGTACGCACGGCCGGTACAGTGAAACTGCGAATGGCTCATTAAATCAGTTATGGTTCCTTTGGTCGCTCGCTCCTCTCCTACTTGGATAACTGTGGTAATTCTAGAGCTAATACATGCCGTCGGGGCTGTCCCCCTTTGTGCGGGATGCGTGCATTTATCAGATCAAAACCAACCCGCGTCAGTTTCCCCCCGGCCCCGCGGNNNNGGTGGGCGTCGGACTGCTTTGGTGACTCTAGATAACCTCGGGCCGATCGCANGCCCCGTGTCGGCATTCGAACGTATGCCCCATCAACTTTCGATGGCAGTCGCCGTGCCTACCATGGTGACCACGGGTGACGGGGAATCAGGGTTCGATTCCGGAGAGGGAGCCTGAGAAACGGCCACCACATCCAAGGAAGGCAGCAGGCGCGCAAATCACCCACTCCCGACCCGGGGAGGTAGCGACGAAAAACAACAACACAGGACTCTTTCGAGAGCCCTGCAATTGGAATGAGTACATTTCAAATCCTTCAACGAGGATCCATTGGAGGGCAAGTCTGGTGCCAGCAGCCGCGGTAATTCCAGCTCCAACAGCGCACATCAAAGTTGCTGCAGTTAAAAAGCTCGTAGTTGGATCTTGTGGAGGGTGCGTAGCGGGCGGTCCGCCGCGAGGCGAGCCACCGCCCGTCCCCGCCCCTTGCCTCTCGGCGCCCCCTCGATGCTCTTAGCTGAGTGTCCCGCGGGGCCCGAAGCGTTTACTTTGAAAAAATTAGAGTGTTCAAAGCAGGCCCGAGCGGCCTAGATACCGCAGCCAGGAATAATGGAACAGGACCGCGGTTCTATTTTGTTGGTTTTCGGAACTGAGGCCATGATTAAGAGGGACGGCCGGGGGCATTCGTATTGCGCCGCTAGAGGTGAAATTCTTGGACCGGCGCAAGACGGACCAGAGCGAAAGCATTTGCCAAGAATGTTTTCATTAATCAAGAACGAAAGTCGGAGGTTTGAAGACGATCAGATACCGTCGTAGTTCCGACCACAAACGATGCCGACTGGCGATGCGGCGGCGTTATTCCCATGACCCGACCGGAACCTTCCGGGAAACCAAAGTCTTTGGGTTCCGGGGGGAGTATGGTTGCAAAGCTGAAACTTAAAGGAATTGACGGAAGGGCACCACCAGGAGTGGATCCTGCGGCCCAATTTGACTCAACACGGGAAACCTCACCCGGCCCGGACACGGACAGGATTGACAGATTGATAGCTCTTTCTCGATTCTGTGGCTGGTGGTGCATGGCTGTTCTTAGTTGCTGGAGCGATTTGTCTGGTTAATTCCGATAACGAACTAGACTCTCGCATGCTAACTAGTCACGCGACCCCCGAGCGGTCGGCGTCCCCCAACTTTTCAGAGGGACAAGTGGCGTTCAGCACCGAGATTGAGCAATAACAGGTCTGTGATGCCCTTAGATGTCCGGTCGGCACGCGCGCTACACTGACTGGCTCAGCGTGTGCTCACCCTACGCCGGCAGGCCGGTAACCCGTTGAACCCCATTCGTGATAGGGATCGGGGATTGCAATTATTTCCCATGAACGAGGAATTCCCAGTAAGTGCGGGTCATAAGCTTGCGTTGATTAAGTCCCTGCCCTTTGTACACACCGCCCGTCGCTACTACCGATTGGATGGTTTAGTGGGCCCTCGGATCGGCCCGCCGGGGTCGGCCCACGGCCCTGGCGGAGCGCTGAGAAGACGGTCGAACTTGACTATCTAGAGGAAGTAAAAGTCGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTA";
            k++;*/
            dataGridView1.Rows.Add();
            dataGridView1.Rows[k].Cells[0].Value = k + 1;
            dataGridView1.Rows[k].Cells[2].Value = "Rattus norvegicus - Серая крыса";
            dataGridView1.Rows[k].Cells[3].Value = "TACCTGGTTGATCCTGCCAGTAGCATATGCTTGTCTCAAAGATTAAGCCATGCATGTCTAAGTACGCACGGCCGGTACAGTGAAACTGCGAATGGCTCATTAAATCAGTTATGGTTCCTTTGGTCGCTCGCTCCTCTCCTACTTGGATAACTGTGGTAATTCTAGAGCTAATACATGCCGACGGGCGCTGACCCCCCTTCCCGTGGGGGGAACGCGTGCATTTATCAGATCAAAACCAACCCGGTCAGCCCCCTCCCGGCTCCGGCCGGGGGTCGGGCGCCGGCGGCTTTGGTGACTCTAGATAACCTCGGGCCGATCGCACGTCCCCGTGGCGGCGACGACCCATTCGAACGTCTGCCCTATCAACTTTCGATGGTAGTCGCCGTGCCTACCATGGTGACCACGGGTGACGGGGAATCAGGGTTCGATTCCGGAGAGGGAGCCTGAGAAACGGCTACCACATCCAAGGAAGGCAGCAGGCGCGCAAATTACCCACTCCCGACCCGGGGAGGTAGTGACGAAAAATAACAATACAGGACTCTTTCGAGGCCCTGTAATTGGAATGAGTCCACTTTAAATCCTTTAACGAGGATCCATTGGAGGGCAAGTCTGGTGCCAGCAGCCGCGGTAATTCCAGCTCCAATAGCGTATATTAAAGTTGCTGCAGTTAAAAAGCTCGTAGTTGGATCTTGGGAGCGGGCGGGCGGTCCGCCGCGAGGCGAGCTCACCGCCCTGTCCCCAGCCCCTGCCTCTCGGCGCCCCCTCGATGCTCTTAGCTGAGTGTCCCGCGGGGCCCGAAGCGTTTACTTTGAAAAAATTAGAGTGTTCAAAGCAGGCCCGAGCCGCCTGGATACCGCAGCTAGGAATAATGGAATAGGACCGCGGTTCTATTTTGTTGGTTTTCGGAACTGAGGCCATGATTAAGAGGGACGGCCGGGGGCATTCGTATTGCGCCGCTAGAGGTGAAATTCTTGGACCGGCGCAAGACGAACCAGAGCGAAAGCATTTGCCAAGAATGTTTTCATTAATCAAGAACGAAAGTCGGAGGTTCGAAGACGATCAGATACCGTCGTAGTTCCGACCATAAACGATGCCGACTGGCGATGCGGCGGCGTTATTCCCATGACCCGCCGGGCAGCTTCCGGGAAACCAAAGTCTTTGGGTTCCGGGGGGAGTATGGTTGCAAAGCTGAAACTTAAAGGAATTGACGGAAGGGCACCACCAGGAGTGGAGCCTGCGGCTTAATTTGACTCAACACGGGAAACCTCACCCGGCCCGGACACGGACAGGATTGACAGATTGATAGCTCTTTCTCGATTCCGTGGGTGGTGGTGCATGGCCGTTCTTAGTTGGTGGAGCGATTTGTCTGGTTAATTCCGATAACGAACGAGACTCTCGGCATGCTAACTAGTTACGCGACCCCCGAGCGGTCGGCGTCCCCCAACTTCTTAGAGGGACAAGTGGCGTTCAGCCACCGAGATTGAGCAATAACAGGTCTGTGATGCCCTTAGATGTCCGGGGCTGCACGCGCGCTACACTGAACTGGCTCAGCGTGTGCCTACCCTACGCCGGCAGGCGCGGGTAACCCGTTGAACCCCATTCGTGATGGGGATCGGGGATTGCAATTATTCCCCATGAACGAGGAATTCCCAGTAAGTGCGGGTCATAAGCTTGCGTTGATTAAGTCCCTGCCCTTTGTACACACCGCCCGTCGCTACTACCGATTGGATGGTTTAGTGAGGCCCTCGGATCGGCCCCGCCGGGGTCGGCCCACGGCCTTGGCGGAGGCCTGAGAAGACGGTCGAACTTGACTATCTAGAGGAAGTAAAAGTCGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTA";
            k++;
            dataGridView1.Rows.Add();
            dataGridView1.Rows[k].Cells[0].Value = k + 1;
            dataGridView1.Rows[k].Cells[2].Value = "Sus scrofa - Кабан";
            dataGridView1.Rows[k].Cells[3].Value = "CGCCCTCGCGTCCCGCGCCGCGCAGGTGGAGGAGGCGAGAGAGCGAGCAGGGCGGGCGGGCAGGCAGACGCGGGCCGCCGCCGCTTGCCACGCTCTCGCCAACGTTAATGATCCTTCCGCAGGTTCACCTACGGAAACCTTGTTACGACTTTTACTTCCTCTAGATAGTCAAGTTCGACCGTCTTCTCAGCGCTCCGCCAGGGCCGTGGGCCGACCCCGGCGGGGCCGATCCGAGGGCCTCACTAAACCATCCAATCGGTAGTAGCGACGGGCGGTGTGTACAAAGGGCAGGGACTTAATCAACGCAAGCTTATGACCCGCACTTACTGGGAATTCCTCGTTCATGGGGAATAATTGCAATCCCCGATCCCCATCACGAATGGGGTTCAACGGGTTACCCGCGCCTGCCGGCGTAGGGTAGGCACACGCTGAGCCAGTCAGTGTAGCGCGCGTGCAGCCCCGGACATCTAAGGGCATCACAGACCTGTTATTGCTCAATCTCGGGTGGCTGAACGCCACTTGTCCCTCTAAGAAGTTGGGGGACGCCGACCGCTCGGGGGTCGCGTAACTAGTTAGCATGCCAGAGTCTCGTTCGTTATCGGAATTAACCAGACAAATCGCTCCACCAACTAAGAACGGCCATGCACCACCACCCACGGAATCGAGAAAGAGCTATCAATCTGTCAATCCTGTCCGTGTCCGGGCCGGGTGAGGTTTCCCGTGTTGAGTCAAATTAAGCCGCAGGCTCCACTCCTGGTGGTGCCCTTCCGTCAATTCCTTTAAGTTTCAGCTTTGCAACCATACTCCCCCCGGAACCCAAAGACTTTGGTTTCCCGGAAGCTGCCCGGCGGGTCATGGGAATAACGCCGCCGCATCGCCAGTCGGCATCGTTTATGGTCGGAACTACGACGGTATCTGATCGTCTTCGAACCTCCGACTTTCGTTCTTGATTAATGAAAACATTCTTGGCAAATGCTTTCGCTCTGGTCCGTCTTGCGCCGGTCCAAGAATTTCACCTCTAGCGGCGCAATACGAATGCCCCCGGCCGTCCCTCTTAATCATGGCCTCAGTTCCGAAAACCAACAAAATAGAACCGCGGTCCTATTCCATTATTCCTAGCTGCGGTATCCAGGCGGCTCGGGCCTGCTTTGAACACTCTAATTTTTTCAAAGTAAACGCTTCGGGCCCCGCGGGACACTCAGCTAAGAGCATCGAGGGGGCGCCGAGAGGCAAGGGGCGGGGACGGGCGGTGGCTCGCCTCGCGGCGGACCGCCCGCCCGCTCCCAAGATCCAACTACGAGCTTTTTAACTGCAGCAACTTTAATATACGCTATTGGAGCTGGAATTACCGCGGCTGCTGGCACCAGACTTGCCCTCCAATGGATCCTCGCGGAAGGATTTAAAGTGGACTCATTCCAATTACAGGGCCTCGAAAGAGTCCTGTATTGTTATTTTTCGTCACTACCTCCCCGGGTCGGGAGTGGGTAATTTGCGCGCCTGCTGCCTTCCTTGGATGTGGTAGCCGTTTCTCAGGCTCCCTCTCCGGAATCGAACCCTGATTCCCCGTCACCCGTGGTCACCATGGTAGGCACGGCGACTACCATCGAAAGTTGATAGGGCAGACGTTCGAATGGGTCGTCGCCGCCACGGAGGGCGTGCGATCGGCCCGAGGTTATCTAGAGTCACCAAAGCCGCCGGCGCCCACCCCCCCGGCCGGGGCCGGGAGGAGGCTGACCGGGTTGGTTTTGATCTGATAAATGCACGCATCCCCCCCGCGAAGGGGGTCAGCGCCCGTCGGCATGTATTAGCTCTAGAATTACCACAGTTATCCAAGTAGGAGAGGAGCGAGCGACCAAAGGAACCATAACTGATTTAATGAGCCATTCGCAGTTTCACTGTACCGGCCGTGCGTACTTAGACATGCATGGCTTAATCTTTGAGACAAGCATATGCTACTGGCAGGATCAACCAGGTAGGAGACGGTGGGACAGCGGGCCGGGTGGACCCCAGCGCAAGGCGTGCATGCTTGCAGGGCGGTGACAGCGGGGTGGGGGCGGAGGCGCACCCCAGGGACCCAGCGGCCCACCACACCCGCAGCGAGGACCGACGACGGGCCGCCCGACAACTCGACCGAGGGCACAAGCGGCGCGGGGCCGCACCGCGGCGTCGCGGAGGGACGAGGGGGGAAGCCCCAAGCTCCCCCACCACCACCACACCCCAGACACGGACCTCCCCCTCGACGGCCCGGGGCACCGAGCAGTCACGTCGGGACCGGCCGACACGCGCGCGCCCTCGCTCGAGC";
            k++;
            dataGridView1.Rows.Add();
            dataGridView1.Rows[k].Cells[0].Value = k + 1;
            dataGridView1.Rows[k].Cells[2].Value = "Zebrias zebra - Рыба?";
            dataGridView1.Rows[k].Cells[3].Value = "TCTGGTTGATTCTGCCAGTAGCATATGCTTGCCTCAAAGATTAAGCCATGCAAGTCTAAGTACACACGGCCGGTACAGTGAAACTGCGAATGGCTCATTAAATCAGTTATGGTTCCTTTGATCGCTCTCACGTTACTTGGATAACTGTGGCAATTCCAGAGCTAATACATGCCAACGGGCGCTGACCTCCGGGGACGCGTGCATTTATCAGACCCAAAACCCATGCGGGGTGCTCCTCACGGGGTGCCCCGGCCGCTTTGGTGACTCTAGATAACCTCGAGCTGATCGCTGGCCCTCGTGGCGGCGACGTCTCATTCGAATGTCTGCCCTATCAACTTTCGATGGTACTTTTTGTGCCTACCATGGTGACCACGGGTAACGGGGAATCAGGGTTCGATTCCGGAGAGGGAGCCTGAGAAACGGCTACCACATCCAAGGAAGGCAGCAGGCGCGCAAATTACCCACTCCCGACTCGGGGAGGTAGTGACGAAAAATAACAATACAGGACTCTTTCGAGGCCCTGTAATTGGAATGAGTACACTTTAAATCCTTTAACGAGGATCCATTGGAGGGCAAGTCTGGTGCCAGCAGCCGCGGTAATTCCAGCTCCAATAGCGTATCTTAAAGTTGCTGCAGTTAAAAAGCTCGTAGTTGGACCTCGGGATCGAGCTGACGGTCCGCCGCGAGGCGAGCTACCGTCTGTCCCAGCCCCTGCCTCTCGGCGCCCCCTCGATGCTCTTAGCTGAGTGTCCCGCGGGGTCCGAAGCGTTTACTTTGAAAAAATTAGAGTGTTCAAAGCAGGCCCGGTCGCCTGAATACCGCAGCTAGGAATAATGGAATAGGACTCCGGTTCTATTTTGTGGGTTTTCTTCTCTGAACTGGGGCCATGATTAAGAGGGACGGCCGGGGGCATTCGTATTGTGCCGCTAGAGGTGAAATTCTTGGACCGGCGCAAGACGGACGAAAGCGAAAGCATTTGCCAAGAATGTTTTCATTAATCAAGAACGAAAGTCGGAGGTTCGAAGACGATCAGATACCGTCGTAGTTCCGACCGTAAACGATGCCAACTAGCGATCCGGCGGCGTTATTCCCATGACCCGCCGGGCAGCGTCCGGGAAACCAAAGTCTTTGGGTTCCGGGGGAGTATGGTTGCAAAGCTGAAACTTAAAGGAATTGACGGAAGGGCACCACCAGGAGTGGAGCCTGCGGCTTAATTTGACTCAACACGGGAAACCTCACCCGGCCCGGACACGGAAAGGATTGACAGATTGATAGCTCTTTCTCGATTCTGTGGGTGGTGGTGCATGGCCGTTCTTAGTTGGTGGAGCGATTTGTCTGGTTAATTCCGATAACGAACGAGACTCCGGCATGCTAACTAGTTACGCGGCCCCGTGCGGTCGGCGTCCAACTTCTTAGAGGGACAAGTGGAATTTAGCCACACGAGATTGAGCAATAACAGGTCTGTGATGCCCTTAGATGTCCGGGGCTGCACGCGCGCCACACTGACTGGATCAGCGTGTGTCTACCCTTCGCCGAGAGGCGCGGGTAACCCGCTGAACCCCACTCGTGATAGGGATTGGGGATTGCAATTATTTCCCATGAACGAGGAATTCCCAGTAAGCGCGGGTCATAAGCTCGCGTTGATTAAGTCCCTGCCCTTTGTACACACCGCCCGTCGCTACTACCGATTGGATGGTTTAGTGAGGTCCTCGGATCGGCCCCGCCGGAGTCGGTAACGGCCCTGGCGGAGTGCCGAGAAGACGATCAAACTTGACTATCTAGAGGAAGTAAAAGTCGTAACAAGGTTTCCGTAGGTGAACCTGCGGAAGGATCATTA";
            k++;

            //Заполнеие таблицы с характеристиками
            dataGridView4.Rows.Add();
            dataGridView4.Rows[0].Cells[0].Value = "AlphabetPower";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[1].Cells[0].Value = "ArithmeticMean";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[2].Cells[0].Value = "AverageRemoteness";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[3].Cells[0].Value = "Count";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[4].Cells[0].Value = "CutLength";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[5].Cells[0].Value = "CutLengthVocabularyEntropy";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[6].Cells[0].Value = "DescriptiveInformation";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[7].Cells[0].Value = "Gamut";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[8].Cells[0].Value = "GeometricMiddling";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[9].Cells[0].Value = "IdentificationInformation";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[10].Cells[0].Value = "IntervalsCount";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[11].Cells[0].Value = "Length";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[12].Cells[0].Value = "NomalizationGamut";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[13].Cells[0].Value = "Periodicity";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[14].Cells[0].Value = "PhantomMessagesCount";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[15].Cells[0].Value = "Probability";
            dataGridView4.Rows.Add();
            dataGridView4.Rows[16].Cells[0].Value = "Regularity";
        }

        /// <summary>
        /// Контейнер с исходными данными для вычислений
        /// </summary>
        private DataContainer SourceData = null;
        /// <summary>
        /// Контейнер с результатами вычислений
        /// </summary>
        private ResultContainer Result = null;
        /// <summary>
        /// Контроллер
        /// </summary>
        private CalculatorController Controller = null;

        /// <summary>
        /// События нажатия на кнопку "Выполнить кластеризацию"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            //на время вычислений делаем недоступными элементы управления
            dataGridView1.Enabled = false;
            dataGridView4.Enabled = false;
            groupBox2.Enabled = false;
            try
            {
                //заполняем контейнер с исходными данными
                SourceData = ParseData();
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                //в случае исключения делаем доступными элементы управления
                EnableMainControls();
                return;
            }
            //и очищаем таблицы с результатами
            dataGridView5.Rows.Clear();
            dataGridView5.Columns.Clear();
            //запускаем вычисления в отдельной нити
            backgroundWorker1.RunWorkerAsync(SourceData);

        }

        /// <summary>
        /// Метод разбора данных с формы
        /// </summary>
        /// <returns>Результаты кластеризации</returns>
        private DataContainer ParseData()
        {
            DataContainer data = new DataContainer();
            //заполняем массив цепочек ДНК
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                //Проверка отмечена ли цепочка
                if (Convert.ToBoolean(dataGridView1.Rows[i].Cells[1].Value))
                {
                    //извлекаем номер цепочки в БД
                    int number = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value);
                    if (number <= 0)
                    {
                        throw new Exception("недопустимый номер цепочки");
                    }
                    //Название ДНК
                    string name = dataGridView1.Rows[i].Cells[2].Value.ToString();
                    //ДНК
                    string dna = dataGridView1.Rows[i].Cells[3].Value.ToString();
                    data.DNAs.Add(new DNAData(number, name, dna));
                }
            }

            //выбор характеристик для вычисления
            for (int j = 0; j < dataGridView4.Rows.Count; j++)
            {
                if (Convert.ToBoolean(dataGridView4.Rows[j].Cells[1].Value))
                {
                    data.Caracteristics.Add(dataGridView4.Rows[j].Cells[0].Value.ToString());
                }
            }
            if (data.Caracteristics.Count == 0)
            {
                throw new Exception("Не выбрано ни одной характеристики для вычисления");
            }
            //выбор представления цепочек
            if (!(checkBox1.Checked || checkBox2.Checked || checkBox3.Checked))
            {
                throw new Exception("Должны быть выделены типы цепочек для которых вычисляются характеристики");
            }

            //определяем привязку
            if (radioButton1.Checked)
            {
                data.link = LinkUp.Start;
            }
            if (radioButton2.Checked)
            {
                data.link = LinkUp.End;
            }
            if (radioButton3.Checked)
            {
                data.link = LinkUp.Both;
            }
            //определяем необходимые представления генетических цепочек
            data.AminoChains = checkBox3.Checked;
            data.NucleotideChains = checkBox1.Checked;
            data.SimpleNucleotideChains = checkBox2.Checked;

            //нормализация
            data.Normalize = checkBox4.Checked;
            return data;
        }

        /// <summary>
        /// Делает доступными все элементы управления, 
        /// в том числе ответственные за вывод графики.
        /// </summary>
        private void EnableAllControls()
        {
            EnableMainControls();
        }

        /// <summary>
        /// Делает доступными основные эелементы управления, 
        /// позволяющие задавать входные данные и запускать вычисления.
        /// </summary>
        private void EnableMainControls()
        {
            dataGridView1.Enabled = true;
            dataGridView4.Enabled = true;
            groupBox2.Enabled = true;
        }

        /// <summary>
        /// Запуск нити осуществляющей кластеризацию
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker Worker = sender as BackgroundWorker;
            Controller = new CalculatorController();
            e.Result = Controller.Divide((DataContainer)e.Argument);
            if (Worker.CancellationPending)
            {
                e.Cancel = true;
            }
        }

        /// <summary>
        /// Событие, возникающее по завершении вычислений
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //если вычисления были отменены
            if (e.Cancelled)
            {
                MessageBox.Show("Исследование отменено", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            //Если произошло исключение
            else if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                //сохраняем результат
                Result = (ResultContainer)e.Result;

                //заполнение списка характеристик для построения графиков
                //Добавляем колонку "название цепочки"
                dataGridView5.Columns.Add(new DataGridViewColumn(dataGridView1.Columns[2].CellTemplate));
                dataGridView5.Columns[0].HeaderText = "Название цепочки";
                dataGridView5.Columns[0].Width = 150;
                dataGridView5.Columns[0].SortMode = dataGridView1.Columns[2].SortMode;
                dataGridView5.Columns.Add(new DataGridViewColumn(dataGridView1.Columns[0].CellTemplate));
                dataGridView5.Columns[1].HeaderText = "Номер цепочки";
                dataGridView5.Columns[1].SortMode = dataGridView1.Columns[2].SortMode;
                dataGridView5.Columns[1].Width = 50;
                //в цикле добавляем колонки для каждой из характеристик и именуем)
                for (int j = 0; j < ((SoapDataObject)Result.dataTable.Objects[0]).vault.Count; j++)
                {
                    dataGridView5.Columns.Add(new DataGridViewColumn(dataGridView1.Columns[2].CellTemplate));
                    dataGridView5.Columns[j + 2].Width = 150;
                    string characteristicname = ((SoapDataCharacteristic)((SoapDataObject)Result.dataTable.Objects[0]).vault[j]).Key;
                    dataGridView5.Columns[j + 2].HeaderText = characteristicname;
                    dataGridView5.Columns[j + 2].SortMode = dataGridView1.Columns[2].SortMode;
                }

                //очистка таблицы
                dataGridView5.Rows.Clear();
                // Цикл заполнения таблицы характеристик
                for (int i = 0; i < Result.dataTable.Objects.Count; i++)
                {
                    dataGridView5.Rows.Add();
                    for (int l = 0; l < SourceData.DNAs.Count; l++)
                    {
                        // Выводим имя цепочки по номеру
                        if (SourceData.DNAs[l].Number == ((SoapDataObject)Result.dataTable.Objects[i]).id)
                        {
                            dataGridView5.Rows[i].Cells[0].Value = SourceData.DNAs[l].Name;
                            dataGridView5.Rows[i].Cells[1].Value = SourceData.DNAs[l].Number;
                        }
                    }
                    for (int m = 0; m < ((SoapDataObject)Result.dataTable.Objects[i]).vault.Count; m++)
                    {
                        dataGridView5.Rows[i].Cells[m + 2].Value = ((SoapDataCharacteristic)((SoapDataObject)Result.dataTable.Objects[i]).vault[m]).Value;
                    }
                }
            }

            label8.Text = "Время вычисления характеристик (мс): " +
                          Result.CharacteristicCalculationTime.TotalMilliseconds.ToString();
            label8.Visible = true;

            //делаем доступными элементы управления
            EnableAllControls();
            button2.Enabled = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                String pathToFile = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\ClusterizationTemp.xml";
                XmlWriter writer = new XmlTextWriter(pathToFile, System.Text.Encoding.UTF8);
                XmlSerializer serialzer = new XmlSerializer(typeof(DataFromDataGrid));

                DataFromDataGrid dataForTransfer = new DataFromDataGrid();
                dataForTransfer.FillFromDataGrid(dataGridView5);
                serialzer.Serialize(writer, dataForTransfer);
                writer.Close();
                Process.Start("C:\\Users\\nick\\Documents\\Visual Studio 2010\\Projects\\ClusterizationClient\\ClusterizationClient\\bin\\Debug\\ClusterizationClient.exe", "-" + pathToFile);
            }
            catch (Exception exeption)
            {
                MessageBox.Show("Произошла ошибка при запуске приложения", exeption.Message);
            }
        }
    }
}